package xiaohu.day1.HJ17;

import java.util.*;


// 模拟行走、别人的解法
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    static class Coordinate{
        int x;
        int y;
        public Coordinate(){
            this.x=0;
            this.y=0;
        }

        public void move(char direction,int dist){
            switch(direction){
                case 'W':
                    this.y+=dist;
                    break;
                case 'S':
                    this.y-=dist;
                    break;
                case 'A':
                    this.x-=dist;
                    break;
                case 'D':
                    this.x+=dist;
                    break;
                default:
                    return;
            }
        }

        public String GetCoordinate(){
            StringJoiner sj=new StringJoiner(",");

            return sj.add(this.x+"").add(this.y+"").toString();
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s=sc.nextLine();

        System.out.println(GetResult(s));
    }

    //判断一个字符串是否为整数
    public static boolean isInteger(String str) {
        try {
            Integer.parseInt(str);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    public static String GetResult(String s){
        String[] cds=s.split(";");

        Coordinate Cd=new Coordinate();

        for(int i=0;i<cds.length;i++){
            //去掉第一个字符，看剩下的是否为一个整数
            if(!isInteger(cds[i].substring(1))){
                i++;
                continue;
            }
            else{
                char direction=cds[i].charAt(0);
                int dist=Integer.parseInt(cds[i].substring(1));
                Cd.move(direction,dist);
            }
        }

        return Cd.GetCoordinate();
    }
}
